<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <title>会议纪要</title>
    <link rel="stylesheet" type="text/css" href="../../css/mui.min.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/style.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/t_style.css"/>
    <script src="../../js/mui.min.js"></script>
    <script src="../../js/jquery.min.js"></script>
    <script src="../../js/vue.js"></script>
    <script src="../../js/main.js"></script>
    <script src="../../js/jquery.flexText.min.js"></script>
</head>
<body>
<div id="app">
    <header class="mui-bar mui-bar-nav">
        <span class="back" @click="back"></span>
        <span class="cross" @click="close"></span>
        <h1 class="mui-title" style="left: 80px;right: 80px">会议纪要</h1>
        <span class="edit-name fr" v-if="type == 1 && isReadOnly" @click="toggle" v-text="edit"></span>
    </header>
    <div class="mui-content" :style="change_style()">
        <ul class="summary-list">
            <li>
                <div class="summary-l">{{meetingTag1}}：</div>
                <div class="summary-r" v-text="title"></div>
            </li>
            <li>
                <div class="summary-l">{{meetingTag2}}：</div>
                <div class="summary-r" v-text="content"></div>
            </li>
            <li>
                <div class="summary-l">{{meetingTag3}}：</div>
                <div class="summary-r" v-text="place"></div>
            </li>
            <li>
                <div class="summary-l">会议时间：</div>
                <div class="summary-r" v-text="createTime"></div>
            </li>
        </ul>
        <div class="summary-content" v-for="item in content_point">
            <p class="summary-title">会议纪要</p>
            <textarea class="summary-info" v-model="item.content" :readonly="isReadOnly"></textarea>
        </div>
        <!--<div class="summary-content" v-if="type == 0 && content_point!=null">
            <p class="summary-title">会议纪要</p>
            <div class="summary-info"  v-text="content_point"></div>
        </div>-->
        <div class="report-footer" v-if="!isReadOnly">
            <div class="submit-btn" @click="toggle">完成</div>
        </div>
    </div>
</div>
</body>
<script>
    function sendInfoToJava(name) {
        //调用android程序中的方法，并传递参数
        javascript:WebView.showInfoFromJs(name);
    }
    var app = new Vue({
        el: "#app",
        data: function () {
            return {
                zgMeetingPointId: "",
                content: "",
                content_point: [],
                createTime: "",
                place: "",
                title: "",
                meetingTag1: "会议主题",
                meetingTag2: "会议内容",
                meetingTag3: "会议地点",
                meetingId: 1,
                isReadOnly: true,
                edit: "修改",
                type: null,
                msg: ""
            }
        },
        methods: {
            back: function () {
                var name = "back";
                sendInfoToJava(name);
            },
            close: function () {
                var name = "close";
                sendInfoToJava(name);
            },
            change_style: function () {
                if (!this.isReadOnly) {
                    return {'padding-bottom': "60px"};
                } else {

                }
            },
            ready: function () {
                var id = GetQueryString("id");
                var this_obj = this;
                this_obj.msg = GetQueryString("msg");
//                if(this_obj.msg == 'add'){
//                    this_obj.isReadOnly = false;
//                }
                this_obj.type = GetQueryString("type");
                var url = "/meeting/zgMeetingPoint/byMeetingId/" + id; //zgMeetingId
                var data = {};

                getAjax(url, function (res) {
                    this_obj.content_point.push({content: res.obj['content_point']});
                    this_obj.content = res.obj['content'];
                    this_obj.createTime = res.obj['time'];
                    this_obj.place = res.obj['place'];
                    this_obj.title = res.obj['title'];
                    this_obj.meetingTag1 = res.obj['meetingTag1'];
                    this_obj.meetingTag2 = res.obj['meetingTag2'];
                    this_obj.meetingTag3 = res.obj['meetingTag3'];
                    this_obj.zgMeetingPointId = res.obj['zgMeetingPointId'];
                    if (this_obj.msg == 'add' && this_obj.type == 1) {
                        this_obj.isReadOnly = false;
                    }
                    console.log(res);
                    this_obj.$nextTick(function () {
                        $('textarea').flexText();
                    })
                }, function (res) {
                    console.log(res);
                })
            },
            toggle: function () {

                var this_obj = this;
                if (this_obj.isReadOnly) {
                    this_obj.isReadOnly = false;
                } else {
                    if (this_obj.content_point[0]['content'] == "") {
                        mui.toast("请输入会议纪要");
                    } else {
                        this_obj.edit = "修改";
                        this_obj.isReadOnly = true;


                        var url = "/meeting/zgMeetingPoint/save";
                        var data = {
                            "meetingId": this_obj.zgMeetingPointId,
                            "content": this_obj.content_point[0]['content'],
                            "loginName": localStorage.userName
                        };
                        common_ajax(url, data, function (res) {
                            if (res.code < 0) {
                                mui.toast(res.errorMsg);
                            } else {
                                if (this_obj.msg == 'add') {
                                    mui.toast("添加成功");
                                } else {
                                    mui.toast("修改成功");
                                }
                            }
                        }, function (res) {
                            mui.toast("修改失败");
                        });
                    }
                }
            }
        }
    });
    app.ready();
    $(function () {
        $('textarea').flexText();
    });

    function GetQueryString(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r != null)return unescape(r[2]);
        return null;
    }
</script>
</html>